package com.rain.shoppingscienceproj.ui.activity.order;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.flyco.tablayout.SlidingTabLayout;
import com.rain.shoppingscienceproj.R;
import com.rain.shoppingscienceproj.ui.activity.BaseActivity;
import com.rain.shoppingscienceproj.ui.adapter.OrderTitleAdapter;
import com.rain.shoppingscienceproj.ui.fragment.order.OrdersFragment;
import com.rain.shoppingscienceproj.ui.fragment.order.PendingPaymentFragment;
import com.rain.shoppingscienceproj.ui.fragment.order.WaitEvaluateFragment;
import com.rain.shoppingscienceproj.ui.fragment.order.WaitGetFragment;
import com.rain.shoppingscienceproj.ui.fragment.order.WaitSendFragment;
import com.rain.shoppingscienceproj.ui.utile.TitleUtils;
import com.rain.shoppingscienceproj.utils.AppManager;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * - @Description:  订单列表
 * - @Author:  rain
 * - @Time:
 */
public class OrderListActivity extends BaseActivity {

    private ArrayList<Fragment> mFragments = new ArrayList<>();

    @BindView(R.id.sliding_tabs)
    SlidingTabLayout mSlidingTabLayout;
    @BindView(R.id.view_pager)
    ViewPager mViewPager;

    private OrderTitleAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_list);
        AppManager.getAppManager().addActivity(this);
        ButterKnife.bind(this);
        TitleUtils.TitleView(this, "我的订单");
        initial();
    }

    private void initial() {
        if (mFragments.size() == 0) {
            mFragments.add(OrdersFragment.newInstance("1"));
            mFragments.add(PendingPaymentFragment.newInstance("2"));
            mFragments.add(WaitSendFragment.newInstance("3"));
            mFragments.add(WaitGetFragment.newInstance("4"));
            mFragments.add(WaitEvaluateFragment.newInstance("5"));
        }
        adapter = new OrderTitleAdapter(getSupportFragmentManager(), mFragments);
        mViewPager.setOffscreenPageLimit(5);
        mViewPager.setAdapter(adapter);
        mSlidingTabLayout.setViewPager(mViewPager);
        mViewPager.setCurrentItem(0);
    }
}
